home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form fReplace
- BackColor = &H00C0C0C0&
- BorderStyle = 1 'Fixed Single
- Caption = "Record Replace"
- ClientHeight = 3390
- ClientLeft = 3630
- ClientTop = 2850
- ClientWidth = 5160
- ControlBox = 0 'False
- Height = 3795
- Icon = 0
- Left = 3570
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 3372
- ScaleMode = 0 'User
- ScaleWidth = 5184
- Top = 2505
- Width = 5280
- Begin ListBox cTableList
- BackColor = &H00FFFFFF&
- Height = 1590
- Left = 240
- Sorted = -1 'True
- TabIndex = 9
- Tag = "OLS"
- Top = 360
- Width = 2295
- End
- Begin ListBox cFieldList
- BackColor = &H00FFFFFF&
- Height = 1590
- Left = 2640
- Sorted = -1 'True
- TabIndex = 0
- Tag = "OLS"
- Top = 360
- Width = 2295
- End
- Begin TextBox cReplaceWith
- BackColor = &H00FFFFFF&
- Height = 288
- Left = 1800
- TabIndex = 5
- Tag = "OLS"
- Top = 2040
- Width = 3132
- End
- Begin TextBox cCondition
- BackColor = &H00FFFFFF&
- Height = 288
- Left = 1800
- TabIndex = 7
- Tag = "OLS"
- Top = 2400
- Width = 3132
- End
- Begin CommandButton OkayButton
- BackColor = &H00C0C0C0&
- Caption = "&OK"
- Default = -1 'True
- Enabled = 0 'False
- Height = 372
- Left = 600
- TabIndex = 3
- Top = 2880
- Width = 1692
- End
- Begin CommandButton CancelButton
- BackColor = &H00C0C0C0&
- Cancel = -1 'True
- Caption = "&Close"
- Height = 372
- Left = 2880
- TabIndex = 4
- Top = 2880
- Width = 1692
- End
- Begin Label TableListLabel
- BackColor = &H00C0C0C0&
- Caption = "Table List:"
- Height = 190
- Left = 240
- TabIndex = 8
- Top = 120
- Width = 1212
- End
- Begin Label ConditionLabel
- BackColor = &H00C0C0C0&
- Caption = "Condition:"
- Height = 252
- Left = 240
- TabIndex = 6
- Top = 2400
- Width = 1332
- End
- Begin Label ReplaceWithLabel
- BackColor = &H00C0C0C0&
- Caption = "Replace With:"
- Height = 252
- Left = 240
- TabIndex = 2
- Top = 2040
- Width = 1452
- End
- Begin Label FieldListLabel
- BackColor = &H00C0C0C0&
- Caption = "Field List:"
- Height = 190
- Left = 2640
- TabIndex = 1
- Top = 120
- Width = 1212
- End
- Option Explicit
- Sub CancelButton_Click ()
- Unload Me
- End Sub
- Sub cFieldList_Click ()
- If Len(cFieldList) > 0 And Len(cReplaceWith) > 0 Then
- OkayButton.Enabled = True
- Else
- OkayButton.Enabled = False
- End If
- End Sub
- Sub cReplaceWith_Change ()
- If Len(cFieldList) > 0 And Len(cReplaceWith) > 0 Then
- OkayButton.Enabled = True
- Else
- OkayButton.Enabled = False
- End If
- End Sub
- Sub cTableList_Click ()
- Dim i As Integer
- cFieldList.Clear
- For i = 0 To gCurrentDB.TableDefs(cTableList).Fields.Count - 1
- cFieldList.AddItem gCurrentDB.TableDefs(cTableList).Fields(i).Name
- Next
- End Sub
- Sub Form_Load ()
- Height = 3792
- Width = 5280
- Left = (Screen.Width - Width) / 2
- Top = (Screen.Height - Height) / 2
- End Sub
- Sub Form_Paint ()
- Outlines Me
- End Sub
- Sub OkayButton_Click ()
- Dim rp As String 'replace with string
- Dim wh As String 'where condition
- Dim r As Long 'return from execute sql
- On Error GoTo ReplaceErr
- MsgBar "Replacing Records", True
- If gCurrentDB.TableDefs(cTableList).Fields(cFieldList).Type = FT_STRING Then
- rp = "'" & cReplaceWith & "'"
- Else
- rp = cReplaceWith
- End If
- If Len(cCondition) = 0 Then
- wh = NULL_STR
- Else
- wh = " where " & cCondition
- End If
- If gstDataType = SQLDB Then
- r = gCurrentDB.ExecuteSQL("update " & cTableList & " set " & cFieldList & "=" & rp + wh)
- If r > 0 Then
- If gfTransPending Then gfDBChanged = True
- End If
- Else
- gCurrentDB.Execute "update " & cTableList & " set [" & cFieldList & "]=" & rp + wh
- End If
- Unload Me
- GoTo ReplaceEnd
- ReplaceErr:
- ShowError
- Resume ReplaceEnd
- ReplaceEnd:
- MsgBar NULL_STR, False
- End Sub
-